unit cmdRedrawContextAndGetChanges;

interface

uses  classes, sysutils
    , nativeXml
    , appMappldXmlNode
    , appMappldXmlCommand
    , appMappldTypes
    , appMappldXmlContext
;

type
    {------------------------------ TCmdRedrawContextAndGetChanges }

    {***************************************************************************
    * TCmdRedrawContextAndGetChanges
    ***************************************************************************}
    TCmdRedrawContextAndGetChanges = class( TMappldXmlCommand )
protected
    procedure   internalProccess(); override;
    procedure   internalPrepareResult( aResultNode : TMappldXmlNode ); override;

    end;

implementation

{*******************************************************************************
* internalProccess
*******************************************************************************}
procedure TCmdRedrawContextAndGetChanges.internalProccess();
var
    fileName : string;

begin
    FxmlContext.updateRuntimeValues( FxmlNode );
//    Fcontext.centerX := Fcontext.centerX + 100;

    fileName := Foptions.mapDir + '\' + Fticket + '.jpg';
    Fcontext.saveMapBitmapToFileAsJpeg( fileName );
end;

{*******************************************************************************
* internalPrepareResult
*******************************************************************************}
procedure TCmdRedrawContextAndGetChanges.internalPrepareResult( aResultNode : TMappldXmlNode );
begin
    aResultNode.Name := XML_C_GetMapImage;
    aResultNode.ValueAsString := Fticket;
end;

initialization

TMappldXmlCommand.registerCommandByCode( XML_C_TCmdRedrawContextAndGetChanges, TCmdRedrawContext );

end.
